#include <cstdio>

const int maxn = 66000*2;
int size = 0;

struct tt
{
    //col记录区间的染色情况,cnt记录区间的取反次数
    int ll, rr, col, cnt;
} p[maxn*4];

struct seg
{
    int s, e;
} ans[maxn];

void build( int s, int e, int num )
{
    p[num].ll = s;
    p[num].rr = e;
    p[num].col = p[num].cnt = 0;

    if( s - e )
    {
        int m = (s+e)/2;
        build( s, m, num*2+1 );
        build( m+1, e, num*2+2 );
    }
}

void update( int s, int e, int num, int k )
{
    if( p[num].ll == s && p[num].rr == e )
    {
        p[num].col = k;
        p[num].cnt = 0;
        return;
    }

    if( p[num].col + 1 )
    {
        if( p[num].cnt%2 )
            p[num].col = !p[num].col;
        p[num*2+1].col = p[num*2+2].col = p[num].col;
        p[num*2+1].cnt = p[num*2+2].cnt = p[num].cnt = 0;
        p[num].col = -1;
    }

    if( p[num].cnt%2 )
    {
        p[num*2+1].cnt++;
        p[num*2+2].cnt++;
        p[num].cnt = 0;
    }

    int m = (p[num].ll + p[num].rr)/2;
    if( m >= e )
        update(s, e, num*2+1, k);
    else if( m < s )
        update(s, e, num*2+2, k);
    else
    {
        update(s, m, num*2+1, k);
        update(m+1, e, num*2+2, k);
    }
}

void update( int s, int e, int num )
{
    if( p[num].ll == s && p[num].rr == e )
    {
        p[num].cnt++;
        return;
    }

    if( p[num].col + 1 )
    {
        if( p[num].cnt%2 )
            p[num].col = !p[num].col;
        p[num*2+1].col = p[num*2+2].col = p[num].col;
        p[num*2+1].cnt = p[num*2+2].cnt = p[num].cnt = 0;
        p[num].col = -1;
    }

    if( p[num].cnt%2 )
    {
        p[num*2+1].cnt++;
        p[num*2+2].cnt++;
        p[num].cnt = 0;
    }

    int m = (p[num].ll + p[num].rr)/2;
    if( m >= e )
        update(s, e, num*2+1);
    else if( m < s )
        update(s, e, num*2+2);
    else
    {
        update(s, m, num*2+1);
        update(m+1, e, num*2+2);
    }
}

void query( int s, int e, int num )
{
    if( p[num].col + 1 )
    {
        if( p[num].cnt%2 )
        {
            p[num].col = !p[num].col;
            p[num].cnt = 0;
        }
        if( p[num].col == 1 )
        {
            ans[size].s = s;
            ans[size++].e = e;
        }
        
        return;
    }

    if( p[num].cnt%2 )
    {
        p[num*2+1].cnt++;
        p[num*2+2].cnt++;
        p[num].cnt = 0;
    }

    int m = (p[num].ll+p[num].rr)/2;
    if( m >= e )
        query( s, e, num*2+1 );
    else if( m < s )
        query( s, e, num*2+2 );
    else
    {
        query( s, m, num*2+1 );
        query( m+1, e, num*2+2 );
    }
}

int main()
{
    int aa, bb, start, end;
    char s[20], lk, rk;

    build(0, maxn-1, 0);
    while( scanf("%s", s) != EOF )
    {
        scanf("%c", &lk);
        scanf("%c%d,%d%c", &lk, &aa, &bb, &rk);
        aa *= 2;    bb *= 2;
        if( lk == '(' )
            aa += 1;
        if( rk == ')' )
            bb -= 1;
        
        switch(s[0])
        {
            case 'U':
                if(aa <= bb)
                    update(aa, bb, 0, 1);
                break;
            case 'I':
                if( aa > 0 )
                    update(0, aa-1, 0, 0);
                update(bb+1, maxn-1, 0, 0);
                break;
            case 'D':
                if(aa <= bb)
                    update(aa, bb, 0, 0);
                break;
            case 'C':
                if( aa > 0 )
                    update(0, aa-1, 0, 0);
                update(bb+1, maxn-1, 0, 0);
                if(aa <= bb)
                    update(aa, bb, 0);
                break;
            case 'S':
                if(aa <= bb)
                    update(aa, bb, 0);
                break;
        }
    }

    query(0, maxn-1, 0);
    if( !size )
        printf("empty set");
    else
    {
        for( int i = 0; i < size; ++i )
        {
            start = ans[i].s;
            while( i < size-1 && ans[i].e == ans[i+1].s - 1 )
                ++i;
            end = ans[i].e;
            if(start % 2)
                printf("(%d,", start/2);
            else
                printf("[%d,", start/2);
            if(end % 2)
                printf("%d) ", (end+1)/2);
            else
                printf("%d] ", end/2);
        }
    }

    printf("\n");

    return 0;
}
